﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using WindowsFormProject.Depo;

namespace WindowsFormProject.Depo.Alislar
{
    public class AlisProvider
    {
        private AlisProvider()
        { }

        public static DataTable AlislarByDataTable()
        {
            DataBaseProvider MyDatabase = new DataBaseProvider();
            return MyDatabase.ExecuteDataTable("[MySp_SelectAlislar]", CommandType.StoredProcedure, "Alislar");
        }
        public static int InsertAlis(DataRow MyDataRow)
        {
            int ReturnValue = 0;

            DataBaseProvider MyDatabase = new DataBaseProvider();
            MyDatabase.AddInParameter("@PersonelID", SqlDbType.NVarChar, MyDataRow["PersonelID"].ToString());
            MyDatabase.AddInParameter("@TedarikciID", SqlDbType.Int,Convert.ToInt32(MyDataRow["TedarikciID"]));
            MyDatabase.AddInParameter("@AlisFaturaNo", SqlDbType.NVarChar, MyDataRow["AlisFaturaNo"].ToString());
            //MyDatabase.AddInParameter("@AlisFaturaTarihi", SqlDbType.DateTime,Convert.ToDateTime(MyDataRow["AlisFaturaTarihi"]) );
            //MyDatabase.AddInParameter("@AlisIrsaliyeTarihi", SqlDbType.DateTime,Convert.ToDateTime(MyDataRow["AlisIrsaliyeTarihi"]));
           

            MyDatabase.AddOutParameter("@AlisID", SqlDbType.Int);
            ReturnValue = Convert.ToInt32(MyDatabase.ExecuteNonQuery("[MySp_InsertAlis]", CommandType.StoredProcedure, "@AlisID"));
            return ReturnValue;


        }
        public static int UpdateAlis(DataRow MyDataRow)
        {
            int ReturnValue = 0;
            DataBaseProvider MyDatabase = new DataBaseProvider();
            //MyDatabase.AddInParameter("@TedarikciFirmaAdi", SqlDbType.NVarChar, MyDataRow["TedarikciFirmaAdi"]);
            //MyDatabase.AddInParameter("@TedarikciVergiNo", SqlDbType.NVarChar, MyDataRow["TedarikciVergiNo"]);
            //MyDatabase.AddInParameter("@TedarikciVergiDairesi", SqlDbType.NVarChar, MyDataRow["TedarikciVergiDairesi"]);
            //MyDatabase.AddInParameter("@TedarikciIletisimAdresi", SqlDbType.NVarChar, MyDataRow["TedarikciIletisimAdresi"]);
            //MyDatabase.AddInParameter("@TedarikciYetkliAdiSoyadi", SqlDbType.NVarChar, MyDataRow["TedarikciYetkliAdiSoyadi"]);
            //MyDatabase.AddInParameter("@TedarikciAciklama", SqlDbType.NVarChar, MyDataRow["TedarikciAciklama"]);
            //MyDatabase.AddInParameter("@TedarikciID", SqlDbType.Int,Convert.ToInt32(MyDataRow["TedarikciID"]));
            ReturnValue = Convert.ToInt32(MyDatabase.ExecuteNonQuery("[MySp_UpdateAlis]", CommandType.StoredProcedure));
            return ReturnValue;
        }
    }
}
